package cc.dd.marketing.activity.rule.checker;

import cc.dd.marketing.activity.dto.PullPInnerDTO;
import cc.dd.marketing.activity.rule.domain.ActivityStatusRule;
import cc.dd.marketing.common.ActivityStatusEnum;
import cc.dd.marketing.rule.base.RuleChecker;
import cc.dd.marketing.system.exception.base.BusinessException;
import cc.dd.marketing.system.exception.response.ResultCodeEnum;
import org.springframework.stereotype.Component;

/**
 * 活动状态规则校验
 *
 * @author dongsufeng
 * @date 2022/9/9 11:39 AM
 */
@Component
public class ActivityStatusRuleChecker implements RuleChecker<ActivityStatusRule, PullPInnerDTO> {

    @Override
    public Boolean validate(ActivityStatusRule rule, PullPInnerDTO request) {
        if (rule.getRule() != ActivityStatusEnum.PROCESSING.getCode()) {
            throw new BusinessException(ResultCodeEnum.RULE_CHECK_FAIL.getCode(), "活动状态不是进行中");
        }
        return true;
    }
}
